package com.xyc.user.service;

import com.xyc.common.utils.SecurityUtils;
import com.xyc.user.dao.UserMapper;
import com.xyc.user.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@Service("userServiceImpl")
public class UserServiceImpl implements UserService{


    @Autowired
    private UserMapper userMapper;
/**
 *@Author xyc
 *@Date 2017/9/9/009 下午:17:39
 *@Description 根据用户名查询用户
 */
    @Override
    public User findUserByUserName(String username) {

        User user=userMapper.selectByUserName(username);

        return user;
    }

    @Override
    public void createUser(User user) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
        userMapper.insertSelective(user);
    }
}
